clear all
set more off
set matsize 800
cd "replication_materials/data"

insheet using "dt_replication.csv", clear
keep if developed!="1"
keep iso3c year outgaptdl lgdppcap democracy gdppcapgrowth limports lexports lelecconspc lpop outgapgdphamilton capacity lpopdensity

destring *, replace ignore("NA") 

/* ssc  install xtabond2 */
sort iso3c year
encode iso3c, gen(iso3c_code)
xtset iso3c_code year
qui tab year, g(yr)
qui tab iso3c, g(ccode)

gen lnlpop = ln(lpop)
gen lnlgdppcap2 = ln(lgdppcap)

global covar = "limports lexports lnlpop lnlgdppcap2 lelecconspc lpopdensity"


cd "~/Dropbox/Research/Papers/ElectricityTheft/PoliticalRegimesLosses/replication_materials/tables/OA"
cap erase T13_appendix_gmm2.tex


xtabond2 outgaptdl L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton  yr1-yr46 , gmm(outgaptdl, lag(3 4) eq(both)) iv(yr1-yr46, eq(level)) 
outreg2 using T13_appendix_gmm2, tex dec(3) keep(L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton  $covar) nocons
*unique ccode if e(sample)

xtabond2 outgaptdl L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton  yr1-yr46 , gmm(outgaptdl, lag(3 6) eq(both)) iv(yr1-yr46, eq(level)) 
outreg2 using T13_appendix_gmm2, tex dec(3) keep(L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton  $covar) nocons
*unique ccode if e(sample)

xtabond2 outgaptdl L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton  yr1-yr46 $covar, gmm(outgaptdl, lag(3 4) eq(both)) iv(yr1-yr46 $covar, eq(level)) 
outreg2 using  T13_appendix_gmm2, tex dec(3) keep(L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton  $covar) nocons
*unique ccode if e(sample)

xtabond2 outgaptdl L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton  yr1-yr46 $covar, gmm(outgaptdl, lag(3 6) eq(both)) iv(yr1-yr46 $covar, eq(level)) 
outreg2 using  T13_appendix_gmm2, tex dec(3) keep(L.outgaptdl L2.outgaptdl c.L.democracy##c.L.outgapgdphamilton $covar) nocons
*unique ccode if e(sample)

